package lan.battletank.logic;

import java.util.Random;

import lan.battletank.element.EnemyBulletEntity;
import lan.battletank.element.EnemyEntity;
import lan.battletank.element.IndicatorEntity;

public class EnemyLogic {
    public static boolean inAction = false;

    private static Random rand = new Random();

    public static void enemyFire(EnemyEntity enemy, EnemyBulletEntity bullet, IndicatorEntity indicator) {
        enemy.startFiring(bullet);
        bullet.setBulletmomentum(getEnemyCannonAngle(), getEnemyFirePower(indicator));
    }

    private static int getEnemyFirePower(IndicatorEntity indicator) {
        switch (indicator.getWindPower()) {
        case -60:
            return 85;
        case -45:
            return 75;
        case -30:
            return 65;
        case -15:
            return 55;
        case 0:
            return 50;
        case 15:
            return 45;
        case 30:
            return 40;
        case 45:
            return 35;
        case 60:
            return 30;
        default:
            return 40;
        }
    }

    private static int getEnemyCannonAngle() {
        return rand.nextInt(40) + 20;
    }
}
